package com.xyht.sca_s.student_manage_system.modules.welcomeNewStudent.config;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xyht.sca_s.student_manage_system.modules.welcomeNewStudent.entity.SmsWnsStudentLoanProcess;
import com.xyht.sca_s.student_manage_system.modules.welcomeNewStudent.mapper.SmsWnsStudentLoanProcessMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

@Component
public class StudentLoanProcessInit {

    @Resource
    private SmsWnsStudentLoanProcessMapper smsWnsStudentLoanProcessMapper;

    private static final List<String> departmentNameList = Arrays.asList("学工处", "财务处");

    @Bean
    public void studentLoanInit() {
        List<SmsWnsStudentLoanProcess> processList = smsWnsStudentLoanProcessMapper.selectList(new QueryWrapper<>());
        if (processList.isEmpty()) {
            int sort = 1;
            for (String departmentName : departmentNameList) {
                SmsWnsStudentLoanProcess addProcess = new SmsWnsStudentLoanProcess();
                addProcess.setProcessName(departmentName);
                addProcess.setProcessIsApplicationEdit(false);
                addProcess.setProcessIsUse(true);
                addProcess.setProcessIsStamp(false);
                addProcess.setProcessIsSign(true);
                addProcess.setProcessSort(sort++);
                smsWnsStudentLoanProcessMapper.insert(addProcess);
            }
        }
    }
}
